package service

// 知识百科Agent相关请求和响应类型定义

// CreateKnowledgeAgentRequest 创建知识百科Agent请求
type CreateKnowledgeAgentRequest struct {
	Name          string   `json:"name" binding:"required"`
	Description   string   `json:"description"`
	Model         string   `json:"model" binding:"required"`
	Categories    []string `json:"categories"`     // 支持的知识分类
	Languages     []string `json:"languages"`      // 支持的语言
	Difficulty    string   `json:"difficulty"`     // easy, medium, hard, expert
	MaxQuestions  int      `json:"max_questions"`  // 最大问题数
	ResponseStyle string   `json:"response_style"` // detailed, concise, educational
	Temperature   float32  `json:"temperature"`    // AI温度参数
	MaxTokens     int      `json:"max_tokens"`     // 最大tokens
	Prompts       []string `json:"prompts"`        // 自定义提示词
	CreatedBy     uint     `json:"created_by"`
}

// StartKnowledgeSessionRequest 开始知识会话请求
type StartKnowledgeSessionRequest struct {
	AgentID  uint   `json:"agent_id" binding:"required"`
	UserID   string `json:"user_id"`
	Topic    string `json:"topic"`    // 主要讨论话题
	Category string `json:"category"` // 知识分类
}

// AskQuestionRequest 提问请求
type AskQuestionRequest struct {
	AgentID   uint   `json:"agent_id" binding:"required"`
	SessionID string `json:"session_id,omitempty"`
	Question  string `json:"question" binding:"required"`
	Language  string `json:"language,omitempty"` // 默认中文
	Context   string `json:"context,omitempty"`  // 上下文信息
}

// AskQuestionResponse 提问响应
type AskQuestionResponse struct {
	ID            uint     `json:"id"`
	Answer        string   `json:"answer"`
	Category      string   `json:"category"`       // 问题分类
	Difficulty    string   `json:"difficulty"`     // 问题难度
	Confidence    float32  `json:"confidence"`     // 置信度
	ResponseTime  int      `json:"response_time"`  // 响应时间(ms)
	TokensUsed    int      `json:"tokens_used"`    // 消耗的tokens
	Suggestions   []string `json:"suggestions"`    // 相关建议
	RelatedTopics []string `json:"related_topics"` // 相关话题
}

// GetKnowledgeHistoryRequest 获取知识历史请求
type GetKnowledgeHistoryRequest struct {
	AgentID    uint   `form:"agent_id"`
	SessionID  string `form:"session_id"`
	Category   string `form:"category"`
	Difficulty string `form:"difficulty"`
	Page       int    `form:"page" binding:"min=1"`
	PageSize   int    `form:"page_size" binding:"min=1,max=100"`
}

// GetKnowledgeHistoryResponse 获取知识历史响应
type GetKnowledgeHistoryResponse struct {
	Questions []KnowledgeQuestionInfo `json:"questions"`
	Total     int                     `json:"total"`
	Page      int                     `json:"page"`
	PageSize  int                     `json:"page_size"`
}

// KnowledgeQuestionInfo 知识问题信息
type KnowledgeQuestionInfo struct {
	ID           uint    `json:"id"`
	Question     string  `json:"question"`
	Answer       string  `json:"answer"`
	Category     string  `json:"category"`
	Difficulty   string  `json:"difficulty"`
	Language     string  `json:"language"`
	ModelUsed    string  `json:"model_used"`
	TokensUsed   int     `json:"tokens_used"`
	ResponseTime int     `json:"response_time"`
	Confidence   float32 `json:"confidence"`
	Rating       *int    `json:"rating"`
	Feedback     string  `json:"feedback"`
	IsHelpful    *bool   `json:"is_helpful"`
	CreatedAt    string  `json:"created_at"`
}

// RateAnswerRequest 评分请求
type RateAnswerRequest struct {
	QuestionID uint   `json:"question_id" binding:"required"`
	Rating     int    `json:"rating" binding:"required,min=1,max=5"`
	Feedback   string `json:"feedback"`
	IsHelpful  *bool  `json:"is_helpful"`
}

// KnowledgeAnalyticsResponse 知识分析响应
type KnowledgeAnalyticsResponse struct {
	TotalQuestions  int              `json:"total_questions"`
	TotalSessions   int              `json:"total_sessions"`
	UniqueUsers     int              `json:"unique_users"`
	AvgResponseTime int              `json:"avg_response_time"`
	AvgRating       float32          `json:"avg_rating"`
	HelpfulRate     float32          `json:"helpful_rate"`
	CategoryStats   map[string]int   `json:"category_stats"`
	DifficultyStats map[string]int   `json:"difficulty_stats"`
	LanguageStats   map[string]int   `json:"language_stats"`
	TrendData       []DailyStatsData `json:"trend_data"`
}

// DailyStatsData 每日统计数据
type DailyStatsData struct {
	Date      string `json:"date"`
	Questions int    `json:"questions"`
	Sessions  int    `json:"sessions"`
	Users     int    `json:"users"`
}

// KnowledgeAgentConfig 知识Agent配置
type KnowledgeAgentConfig struct {
	Model         string   `json:"model"`
	Temperature   float32  `json:"temperature"`
	MaxTokens     int      `json:"max_tokens"`
	ResponseStyle string   `json:"response_style"`
	Categories    []string `json:"categories"`
	Languages     []string `json:"languages"`
	Prompts       []string `json:"prompts"`
}

// KnowledgeSessionInfo 知识会话信息
type KnowledgeSessionInfo struct {
	ID        string `json:"id"`
	SessionID string `json:"session_id"`
	UserID    string `json:"user_id"`
	Topic     string `json:"topic"`
	Category  string `json:"category"`
	Status    string `json:"status"`
	StartedAt string `json:"started_at"`
	EndedAt   string `json:"ended_at,omitempty"`
}

// UpdateKnowledgeAgentRequest 更新知识Agent请求
type UpdateKnowledgeAgentRequest struct {
	Name          string   `json:"name"`
	Description   string   `json:"description"`
	Categories    []string `json:"categories"`
	Languages     []string `json:"languages"`
	Difficulty    string   `json:"difficulty"`
	MaxQuestions  int      `json:"max_questions"`
	ResponseStyle string   `json:"response_style"`
	Temperature   float32  `json:"temperature"`
	MaxTokens     int      `json:"max_tokens"`
	Prompts       []string `json:"prompts"`
	Status        string   `json:"status"`
	UpdatedBy     uint     `json:"updated_by"`
}

// KnowledgeCategoryRequest 知识分类请求
type KnowledgeCategoryRequest struct {
	Name        string `json:"name" binding:"required"`
	NameEn      string `json:"name_en"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
	Color       string `json:"color"`
	ParentID    *uint  `json:"parent_id"`
	SortOrder   int    `json:"sort_order"`
}

// KnowledgeCategoryResponse 知识分类响应
type KnowledgeCategoryResponse struct {
	ID          uint                        `json:"id"`
	Name        string                      `json:"name"`
	NameEn      string                      `json:"name_en"`
	Description string                      `json:"description"`
	Icon        string                      `json:"icon"`
	Color       string                      `json:"color"`
	Level       int                         `json:"level"`
	SortOrder   int                         `json:"sort_order"`
	IsActive    bool                        `json:"is_active"`
	Children    []KnowledgeCategoryResponse `json:"children,omitempty"`
}

// QuestionBatchRequest 批量提问请求
type QuestionBatchRequest struct {
	AgentID   uint     `json:"agent_id" binding:"required"`
	SessionID string   `json:"session_id,omitempty"`
	Questions []string `json:"questions" binding:"required,min=1,max=10"`
	Language  string   `json:"language,omitempty"`
}

// QuestionBatchResponse 批量提问响应
type QuestionBatchResponse struct {
	Results []AskQuestionResponse `json:"results"`
	Summary QuestionBatchSummary  `json:"summary"`
}

// QuestionBatchSummary 批量提问摘要
type QuestionBatchSummary struct {
	TotalQuestions  int     `json:"total_questions"`
	SuccessCount    int     `json:"success_count"`
	FailureCount    int     `json:"failure_count"`
	TotalTokens     int     `json:"total_tokens"`
	AvgResponseTime int     `json:"avg_response_time"`
	AvgConfidence   float32 `json:"avg_confidence"`
}

// ExportKnowledgeRequest 导出知识请求
type ExportKnowledgeRequest struct {
	AgentID    uint   `form:"agent_id" binding:"required"`
	StartDate  string `form:"start_date"`
	EndDate    string `form:"end_date"`
	Category   string `form:"category"`
	Difficulty string `form:"difficulty"`
	Format     string `form:"format"` // json, csv, xlsx
}

// KnowledgeSearchRequest 知识搜索请求
type KnowledgeSearchRequest struct {
	AgentID  uint   `form:"agent_id"`
	Query    string `form:"query" binding:"required"`
	Category string `form:"category"`
	Language string `form:"language"`
	Page     int    `form:"page" binding:"min=1"`
	PageSize int    `form:"page_size" binding:"min=1,max=50"`
}

// KnowledgeSearchResponse 知识搜索响应
type KnowledgeSearchResponse struct {
	Questions  []KnowledgeQuestionInfo `json:"questions"`
	Total      int                     `json:"total"`
	Page       int                     `json:"page"`
	PageSize   int                     `json:"page_size"`
	SearchTime int                     `json:"search_time"` // 搜索耗时(ms)
}
